// home/enterprise/EnterpriseCategory.js
import api from "../../utils/api.js";
import utils from "../../utils/utils.js";
import network from "../../utils/network.js";
import formatDate from "../../utils/format_date.js";
const app = getApp();


Page({

  /**
   * 页面的初始数据
   */
  data: {
    autoplay: true,
    interval: 5000,
    duration: 300,
    indicatorDots: true,
    circular: true,
    winWidth: 0, // 屏宽
    advBananer: ['http://image.document.guanmai.cn/1550825052828.png',
      'http://image.document.guanmai.cn/1550825052828.png'
    ],
    navigateItem: [{
      'typeName': '智能装备',
      'img': '/images/qiye1.png'
    }, {
      'typeName': '绿色家装',
      'img': '/images/qiye2.png'
    }, {
      'typeName': '循环造纸',
      'img': '/images/qiye3.png'
    }, {
      'typeName': '医药健康',
      'img': '/images/qiye4.png'
    }], // 导航栏
    business: null,
    url: app.globalData.url,
    searchValue : ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    network.postJson(this, api.getQiye).then(res => {
      this.setData({
        business: res.data.data
      })
    })
  },

  onShow:function(e){
    this.setData({
      searchValue: ''
    })
  },


  onNavigateItemClick: function(e) {
    let name = e.currentTarget.dataset.name;
    let index = e.currentTarget.dataset.index;
    wx.navigateTo({
      url: '/home/enterprise/EnterpriseList?name=' + name + '&index=' + index
    })
  },

  goEnterprise: function(e) {
    let id = e.currentTarget.dataset.id;
    let name = e.currentTarget.dataset.name;
    wx.navigateTo({
      url: '/home/enterprise/Enterprise?id=' + id + '&name=' + name + '&type=qiye'
    })
  },

  searchinput: function(e) {
    this.setData({
      searchValue: e.detail.value
    })
  },
  seclaer:function(e){
    this.setData({
      searchValue: ''
    })
  },
   //搜索
   search: function(e) {
    var searchtext = this.data.searchValue; //搜索框的值
    if (searchtext != "") {
      wx.navigateTo({
        url: '/home/enterprise/SearchEnterprise?searchtext=' + searchtext
      })
    } else {
      return;
    }
  },

})